class Solution {//leetcode942——增减字符串匹配
public:
    vector<int> diStringMatch(string s) {
        int n=s.size();
        vector<int> ret(n+1);
        int min_cur=0,max_cur=n;
        for(int i=0;i<n;i++){
            if(s[i]=='I') ret[i]=min_cur++;
            if(s[i]=='D') ret[i]=max_cur--; 
        }
        ret[n]=min_cur;
        return ret;
    }
};